using System.ComponentModel;
using UnityEngine;

[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class ES2_Sprite : ES2Type
{
	public ES2_Sprite()
		: base(typeof(Sprite))
	{
		key = 31;
	}

	public override void Write(object data, ES2Writer writer)
	{
		Sprite sprite = (Sprite)data;
		writer.Write(sprite.texture);
		writer.Write(sprite.rect);
		Vector3 center = sprite.bounds.center;
		float num = 0f - center.x;
		Vector3 extents = sprite.bounds.extents;
		float x = num / extents.x / 2f + 0.5f;
		Vector3 center2 = sprite.bounds.center;
		float num2 = 0f - center2.y;
		Vector3 extents2 = sprite.bounds.extents;
		float y = num2 / extents2.y / 2f + 0.5f;
		writer.Write(new Vector2(x, y));
		float width = sprite.textureRect.width;
		Vector3 size = sprite.bounds.size;
		writer.Write(width / size.x);
		writer.Write(sprite.name);
	}

	public override object Read(ES2Reader reader)
	{
		Sprite sprite = Sprite.Create(reader.Read<Texture2D>(), reader.Read<Rect>(), reader.Read<Vector2>(), reader.Read<float>());
		sprite.name = reader.Read<string>();
		return sprite;
	}
}
